Попытался на базе рутрекера сделать torrеnts.net.ua.
Честно говоря сильно не разбирался, а просто позаменял данные в файлах.
В итоге поиск выдает, что ниодного совпадения не найдено.
Уважаемый Nike28, не подскажете где я ошибся?
INFO
{
"name": "ng_uatracker",
"displayname": "Torrents.net.ua",
"description": "The largest BitTorent tracker in Ukraine",
"version": "1.0",
"site": "http://torrents.net.ua",
"module": "search.php",
"type": "search",
"class": "SynoDLMSearchNGUaTracker"
}
search.php
<?php
class SynoDLMSearchNGUaTracker {
private $wurl = 'http://localhost/ds/uatracker/'; // Web address where Web part located
private $qurl = 'prepare.php?query=%s';
private $turl = '%s.torrent';
private $purl = 'http://torrents.net.ua/forum/';
public function __construct() {
$this->qurl=$this->wurl.$this->qurl;
$this->turl=$this->wurl.$this->turl;
}
public function prepare($curl, $query) {
$url = $this->qurl;
curl_setopt($curl, CURLOPT_URL, sprintf($url, urlencode($query)));
}
public function parse($plugin, $response) {
$input = iconv("cp1251","UTF-8",$response);
$regexp2 = "<tr class=\"tCenter hl-tr\">(.*)<\/tr>";
$regexp_category = "<td.*tracker.php\?f=([0-9]+)\">(.*)<\/a><\/td>";
$regexp_title = "<td.*(viewtopic.php\?t=[0-9]+)\">(.*)<\/a>";
$regexp_download = "download.php?\?t=([0-9]+)\"";
$regexp_size_datetime = "<u>([0-9\,\.]+)<\/u>.*<u>([0-9\,\.]+)<\/u>";
$regexp_seeds = "<td.*\"row4 seedmed\".*([0-9]+)<";
$regexp_leechs = "<td.*\"row4 leechmed\".*([0-9]+)<";
$res=0;
if(preg_match_all("/$regexp2/siU", $input, $matches2, PREG_SET_ORDER)) {
foreach($matches2 as $match2) {
$title="Unknown title";
$download="Unknown download";
$size=0;
$datetime="1978-09-28";
$page="Default page";
$hash="Hash unknown";
$seeds=0;
$leechs=0;
$category="Unknown category";
if(preg_match_all("/$regexp_category/siU", $match2[0], $matches, PREG_SET_ORDER)) {
foreach($matches as $match) {
$category = $match[2];
}
}
if(preg_match_all("/$regexp_title/siU", $match2[0], $matches, PREG_SET_ORDER)) {
foreach($matches as $match) {
$page = $this->purl.$match[1];
$title = str_replace("<wbr>","",$match[2]);
$hash = md5($res.$title);
}
}
if(preg_match_all("/$regexp_download/siU", $match2[0], $matches, PREG_SET_ORDER)) {
foreach($matches as $match) {
$download = sprintf($this->turl, $match[1]);
}
}
if(preg_match_all("/$regexp_size_datetime/siU", $match2[0], $matches, PREG_SET_ORDER)) {
foreach($matches as $match) {
$size = $match[1];
$datetime = date('Y-m-d',$match[2]);
}
}
if(preg_match_all("/$regexp_seeds/siU", $match2[0], $matches, PREG_SET_ORDER)) {
foreach($matches as $match) {
$seeds = $match[1];
}
}
if(preg_match_all("/$regexp_leechs/siU", $match2[0], $matches, PREG_SET_ORDER)) {
foreach($matches as $match) {
$leechs = $match[1];
}
}
if ($title!="Unknown title") {
$plugin->addResult($title, $download, $size, $datetime, $page, $hash, $seeds, $leechs, $category);
$res++;
}
}
}
return $res;
}
}
?>
prepare.php
<?
include('config.php');
$url = 'http://torrents.net.ua/forum/index.php';
$lurl = 'http://torrents.net.ua/forum/login.php';
$queryurl = 'http://torrents.net.ua/forum/tracker.php?t=10&s=2&nm=%s';
$loginpost = 'login_username='.$username.'&login_password='.$userpass.'&ses_short=1&login=%C2%F5%EE%E4';
$fscurl = curl_init();
$headers = array
(
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*;q=0.8',
'Accept-Language: ru,en-us;q=0.7,en;q=0.3',
'Accept-Encoding: deflate',
'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7'
);
curl_setopt($fscurl, CURLOPT_HTTPHEADER,$headers);
curl_setopt($fscurl, CURLOPT_FAILONERROR, 1);
curl_setopt($fscurl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($fscurl, CURLOPT_RETURNTRANSFER,1);
curl_setopt($fscurl, CURLOPT_TIMEOUT, 20);
curl_setopt($fscurl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.4) Gecko/2008102920 AdCentriaIM/1.7 Firefox/3.0.4');
curl_setopt($fscurl, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($fscurl, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($fscurl, CURLOPT_URL, $lurl);
curl_setopt($fscurl, CURLOPT_REFERER, $url);
curl_setopt($fscurl, CURLOPT_POST, 1);
curl_setopt($fscurl, CURLOPT_POSTFIELDS, $loginpost);
curl_exec($fscurl); // Log in
curl_setopt($fscurl, CURLOPT_POST, 0);
curl_setopt($fscurl, CURLOPT_URL, sprintf($queryurl, urlencode($_GET['query'])));
curl_exec($fscurl); // Search
$response = curl_exec($fscurl);
curl_close($fscurl);
echo $response;
?>
torrent.php
<?
include('config.php');
$url = 'http://torrents.net.ua/forum/index.php';
$lurl = 'http://torrents.net.ua/forum/login.php';
$torrenturl = 'http://torrents.net.ua/forum/download.php?t=%s';
$topicurl = 'http://torrents.net.ua/forum/viewtopic.php?t=%s';
$loginpost = 'login_username='.$username.'&login_password='.$userpass.'&ses_short=1&login=%C2%F5%EE%E4';
$torrentid = $_GET['id'];
$fscurl = curl_init();
$headers = array
(
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*;q=0.8',
'Accept-Language: ru,en-us;q=0.7,en;q=0.3',
'Accept-Encoding: deflate',
'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7'
);
curl_setopt($fscurl, CURLOPT_HTTPHEADER,$headers);
curl_setopt($fscurl, CURLOPT_FAILONERROR, 1);
curl_setopt($fscurl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($fscurl, CURLOPT_RETURNTRANSFER,1);
curl_setopt($fscurl, CURLOPT_TIMEOUT, 20);
curl_setopt($fscurl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.4) Gecko/2008102920 AdCentriaIM/1.7 Firefox/3.0.4');
curl_setopt($fscurl, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($fscurl, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($fscurl, CURLOPT_URL, $lurl);
curl_setopt($fscurl, CURLOPT_REFERER, $url);
curl_setopt($fscurl, CURLOPT_POST, 1);
curl_setopt($fscurl, CURLOPT_POSTFIELDS, $loginpost);
curl_exec($fscurl); // Log in
curl_setopt($fscurl, CURLOPT_POST, 1);
curl_setopt($fscurl, CURLOPT_REFERER, sprintf($topicurl, $torrentid));
curl_setopt($fscurl, CURLOPT_URL, sprintf($torrenturl, $torrentid));
curl_setopt($fscurl, CURLOPT_BINARYTRANSFER, 1);
$response = curl_exec($fscurl); // Torrent
curl_close($fscurl);
header('Content-Type: application/x-bittorrent');
header('Content-Disposition: attachment; filename="[uatracker].t'.$torrentid.'.torrent"');
echo $response;
?>